<#include "/@inc/uiMacros.ftl">
<#include "/@inc/funcMacros.ftl">
<#include "/@inc/copyright.txt">
<#assign className = TriaGram + Prefix + LateType + "Dlg">
<#assign intfName = TriaGram + "I" + Prefix + LateType>
<#assign baseName = TriaGram + Prefix + LateType>
<@pp.renameOutputFile name=className+".cpp"></@pp.renameOutputFile>


<#-- Doesnt not work :( <#assign x = ${DataTypes(Attributes) }  -->

<@UI_ELEMENTS_DATA_TYPES Attributes  />

// Local Framework
#include "${className}.h"

// Dialog Framework
#include "CATDlgGridConstraints.h"
#include "CATMsgCatalog.h"

//------------------------------------------------------------------------------------------

${className}::${className}():
      CATDlgDialog (CATApplicationFrame::GetFrame()->GetMainWindow(),"${className}",
                    CATDlgWndBtnOKCancelPreview | CATDlgGridLayout),
{
<@ASSIGN_UI_VARS_NULL uiElements />
}

//--------------------------------------------------------------------------------------

${className}::~${className}()
{
<@ASSIGN_UI_VARS_NULL uiElements />
}

//--------------------------------------------------------------------------------------

void ${className}::Build()
{
<#list uiElements as uiElem>
_${uiElem.name} = new ${uiElem.dlg} (this, "${uiElem.name} ", ${uiElem.style} )
_${uiElem.name} -> SetGridConstraints(${uiElem.row}, ${uiElem.col}, 1, 1, CATGRID_4SIDES);
</#list>
}

<#-- Return the UI ELements -->
<#list Attributes as attrib>
<#list uiElements as uiElem> <#if uiElem.id == attrib.name> <#assign x = uiElem> <#break></#if></#list>
<#switch attrib.ui>
<#case "">
<#break>
<#case "List">
<#case "BiList">
${x.dlg} * ${className}::Get${attrib.name}List()   const
{
	return _${x.name} ;
}
<#break>
<#default >
${x.dlg} * ${className}::Get${x.name}()   const
{
	return _${x.name} ;
}
<#break>
</#switch>
</#list>

<#-- Return the values stored in UI ELements -->
<#list Attributes as attrib>
<#if  (attrib.ui?length > 0 ) >
<#list uiElements as uiElem> <#if uiElem.id == attrib.name> <#assign x = uiElem> <#break></#if></#list>
<#switch attrib.type>
<#case "tk_boolean"><#t>
HRESULT ${className}::Get${attrib.name}( CATBoolean   &     ob${attrib.name} )   const
{
	if(NULL == _${x.name})
	{
		return E_FAIL ;
	}
	// _${x.name} should be CheckButton or Radio Button
	ob${attrib.name}  = ( _${x.name}->GetState() == CATDlgCheck ) ? TRUE : FALSE ;

	return S_OK ;
}
<#break>
<#case "tk_integer"><#t>
HRESULT ${className}::Get${attrib.name}( int   &  on${attrib.name} )   const
{
	if(NULL == _${x.name})
	{
		return E_FAIL ;
	}

	// _${x.name} should be Combo or Editor/ CheckBox/Radio Button
	<#switch x.dlg >
	<#case "CATDlgCombo" >
	on${attrib.name} = _${x.name}->GetLine(_${x.name}->GetSelect()) ;
	<#break>
	<#case "CATDlgEditor">
	on${attrib.name} =  _${x.name}->GetIntegerValue() ;
	<#break>
	<#default>
	on${attrib.name}  = ( _${x.name}->GetState() == CATDlgCheck ) ? 1 : 0 ;
	</#switch>

	return S_OK ;
}
<#break>
<#case "tk_double"><#t>
HRESULT ${className}::Get${attrib.name}( double   &     od${attrib.name} )   const
{
	if(NULL == _${x.name})
	{
		return E_FAIL ;
	}

	// _${x.name} should be Combo or Editor
	<#switch x.dlg >
	<#case "CATDlgCombo" >
	od${attrib.name} = _${x.name}->GetLine(_${x.name}->GetSelect()) ;
	<#break>
	<#case "CATDlgEditor">
	od${attrib.name} =  _${x.name}->GetValue() ;
	<#break>
	</#switch>

	return S_OK ;
}
<#break>
<#case "tk_string">
HRESULT ${className}::Get${attrib.name}( CATUnicodeString   &  oStr${attrib.name} )   const
{
	if(NULL == _${x.name})
	{
		return E_FAIL ;
	}

	// _${x.name} should be Combo or Editor
	<#switch x.dlg >
	<#case "CATDlgCombo" >
	_${x.name}->GetLine(oStr${attrib.name}, _${x.name}->GetSelect()) ;
	<#break>
	<#case "CATDlgEditor">
	oStr${attrib.name} =  _${x.name}->GetText() ;
	<#break>
	</#switch>

	return S_OK ;
}
</#switch></#if></#list>

